<template>
	<view class="maps">
		<map v-if="markers.length" class="mapss" name="ssx" :markers="markers" :longitude="longitude" :latitude="latitude"></map>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				latitude:"",
				longitude:"",
				markers:[]
			};
		},
		created() {
			
			let athis = this
			//获取位置
				uni.getLocation({
					success(res) {	
						athis.latitude= res.latitude
						athis.longitude = res.longitude
					}
				})
				this.gitone()
			
			
		},
		
		methods:{
			
			//获取标记点
			gitone(){
				let bthis = this
				uni.request({
					url:'https://www.fastmock.site/mock/f2f77728643567dca31e8d289b7d0f51/api/mapList',
					method:'GET',
					success(res) {
						// console.log(res);
						res.data.data.forEach(v=>{
							// console.log(v);
							v.iconPath = "/static/message/tu.png"
							// v.width = "20"
							// v.height = "20"
						})
						bthis.markers = res.data.data
						console.log(bthis.markers);
					},
					fail(err) {
						console.log(err);
					}
				})
			},
			
		}
	}
</script>

<style lang="scss">
	page{
		width: 100%;
		height: 100%;
	}
.maps{
	width: 100%;
	height: 100%;
	.mapss{
		width: 100%;
		height: 100%;
	}
}
</style>
